package org.xin.common.config.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.xin.common.util.ip.IPUtil;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author ：xin
 * @date ：Created in 2021/10/3
 * @desc <p>  </p>
 * @modified By：$
 * @version: $
 */
@Slf4j
//@Configuration
public class RequestFilter implements Filter {

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request=(HttpServletRequest) servletRequest;
        HttpServletResponse response=(HttpServletResponse) servletResponse;
        log.warn("访问IP：{}，URL : {}", IPUtil.getIpAddr(request), request.getRequestURL());
        filterChain.doFilter(servletRequest, servletResponse);
    }
}
